import axios from '@/utils/axios'

const userListApi = '/sp_admin/user/list' // 用户列表
const userDetailApi = '/sp_admin/user/detail' // 用户详情
const addUserApi = '/sp_admin/user/create' // 新增永华
const updateUserApi = '/sp_admin/user/update' // 更新用户
const delUserApi = '/sp_admin/user/remove' // 删除用户
const resetUserPwApi = '/sp_admin/user/reset_pw' // 重置密码
const updateUserStatusApi = '/sp_admin/user/change_user_status' // 用户状态
const checkPageJumpToApi = '/sp_admin/sp_mgr/checkPageJumpTo' // 免登陆跳转平台
const pay_platform_loginApi = '/uaa/manage/login/pay_platform_login' // 获取享扫平台登录地址

/**
 * @desc 用户列表
 */
export const userList = ({ data }) => {
  return axios.post(userListApi, data)
}

/**
 * @desc 用户详情
 */
export const userDetail = ({ params }) => {
  return axios({
    url: userDetailApi,
    method: 'get',
    params: params
  })
}

/**
 * @desc 新增用户
 */
export const addUser = ({ data }) => {
  return axios.post(addUserApi, data)
}

/**
 * @desc 更新用户
 */
export const updateUser = ({ data }) => {
  return axios.post(updateUserApi, data)
}

/**
 * @desc 删除用户
 */
export const delUser = ({ params }) => {
  return axios({
    url: delUserApi,
    method: 'delete',
    params: params
  })
}

/**
 * @desc 重置密码
 */
export const resetUserPw = ({ data }) => {
  return axios.post(resetUserPwApi, data)
}

/**
 * @desc 用户状态
 */
export const updateUserStatus = ({ params }) => {
  return axios({
    url: updateUserStatusApi,
    method: 'post',
    params: params
  })
}

/**
 * @desc 免登陆跳转平台
 */
export const checkPageJumpTo = ({ params }) => {
  return axios({
    url: checkPageJumpToApi,
    method: 'post',
    params: params
  })
}

/**
 * @desc 获取享扫平台登录地址
 */
export const pay_platform_login = (params) => {
  return axios({
    url: pay_platform_loginApi,
    method: 'get',
    data: params
  })
}
